package com.elcl.util;

import com.elcl.storage.ApplicationCache;

import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;

public class UriUtils {

	/**
	 * 拨打电话
	 */
	public static void callPhone(String phoneNumber) {
		if (!StringUtils.isBlank(phoneNumber)) {
			Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"
					+ phoneNumber));
			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			ApplicationCache.context.startActivity(intent);
		} else {
			Toast.makeText(ApplicationCache.context, "电话为空", Toast.LENGTH_SHORT)
					.show();
		}
	}

	/**
	 * 拨号界面
	 */
	public static void dialPhone(String phoneNumber) {
		if (!StringUtils.isBlank(phoneNumber)) {
			Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
					+ phoneNumber));
			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			ApplicationCache.context.startActivity(intent);
		} else {
			Toast.makeText(ApplicationCache.context, "电话为空", Toast.LENGTH_SHORT)
					.show();
		}
	}

	/**
	 * @param url
	 *            浏览器
	 */
	public static void startUrl(String url) {
		if (!StringUtils.isBlank(url)) {
			Intent intent = new Intent(Intent.ACTION_VIEW);
			intent.setData(Uri.parse(url));
			ApplicationCache.context.startActivity(intent);
		} else {
			Toast.makeText(ApplicationCache.context, "电话为空", Toast.LENGTH_SHORT)
					.show();
		}
	}

}
